/**
 * 公共模型
 */
const { DataTypes } = require("sequelize");
const sequelize = require("../conf/database");

// 定义登录模型
const Login = sequelize.define(
  "Login",
  {
    id: {
      type: DataTypes.INTEGER,
      primaryKey: true,
      autoIncrement: true,
    },
    nickname: {
      type: DataTypes.STRING,
      allowNull: false,
    },
    username: {
      type: DataTypes.STRING,
      allowNull: false,
    },
    password: {
      type: DataTypes.STRING,
      allowNull: false,
    },
    create_time: {
      type: DataTypes.DATE,
      defaultValue: DataTypes.NOW,
      allowNull: true,
      comment: "创建时间",
    },
    update_time: {
      type: DataTypes.DATE,
      defaultValue: DataTypes.NOW,
      allowNull: true,
      comment: "更新时间",
    },
    delete_time: {
      type: DataTypes.DATE,
      allowNull: true,
      comment: "删除时间",
    },
  },
  {
    tableName: "users", // 映射表名
    timestamps: true, // 不使用自动生成的 `createdAt` 和 `updatedAt` 字段
    paranoid: true, // 启用逻辑删除
    createdAt: "create_time",
    updatedAt: false,
    deletedAt: "delete_time",
  }
);
module.exports = {
  Login,
};
